home *** CD-ROM | disk | FTP | other *** search
/ Internet 53 / INTERNET53.iso / pc / software / windows / building / coldfusion studio evaluation / data1.cab / CFS_Wizards / CFML / TableToJS.wml < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.5 KB  |  43 lines

  1. <WIZSET QueryFieldList = ''>
  2. <WIZSET FieldCount = '0'>
  3. <WIZLOOP index="CurrentField" list="$${Fields}">
  4.     <WIZSET FieldCount = FieldCount + 1>
  5.     <!---- field is in format 'sTable.sField=sType;nSize;bRequired' ---->
  6.     <WIZSET SeparatorPos = Find( CurrentField, '=' )>
  7.     <WIZSET TableFieldName = Left( CurrentField, SeparatorPos - 1 )>
  8.     <WIZSET QueryFieldList = QueryFieldList & TableFieldName & ', '>
  9. </WIZLOOP>
  10. <WIZSET QueryFieldList = Left( QueryFieldList, Len(QueryFieldList) - 2 )>
  11.  
  12. <!--- Query returning detail information for selected item --->
  13. <CFQUERY name="q" dataSource="$${DataSource}">
  14.     SELECT $${QueryFieldList}
  15.     FROM $${Table}
  16. </CFQUERY>
  17.  
  18. <HEAD>
  19.     <TITLE>$${ApplicationName}</TITLE>
  20. </HEAD>
  21. <BODY>
  22.  
  23. <SCRIPT LANGUAGE=javascript>
  24. <!--    
  25.     <!--- Include JS conversion library. Instead of this you can
  26.         use the <SCRIPT src=''> tag inside of the HEAD tag. --->
  27.     <CFINCLUDE TEMPLATE='$${LibraryPath}'>
  28.     
  29.     <!--- Use WDDX to move from CFML data to JS --->;
  30.     <CFWDDX ACTION='cfml2js' INPUT='#q#' TOPLEVELVARIABLE='q'>
  31.     
  32.     <!--- Here you can write your JavaScript code that will
  33.         access the values of the recordset in form
  34.         q.field_name[row], where field_name is the name of the
  35.         column in the recordset and row is zero-based row index --->
  36.     
  37.     <!--- EXAMPLE: Display some data --->
  38.     <CFSET fieldName = LCase( ListFirst( q.ColumnList ))>
  39.     <CFOUTPUT>alert('The #fieldName# on the first row is ' + q.#fieldName#[0]);</CFOUTPUT>
  40. //-->    
  41. </SCRIPT>
  42.  
  43. </BODY>